package com.dubbo.microserviceweb.error;

//包装器业务异常类实现
public class BussinessException extends Exception implements CommonError {

    private CommonError commonError;

    //直接接受EmbusinessError的传参用于构造业务异常
    public BussinessException(CommonError commonError){
        super();
        this.commonError = commonError;
    }

    //接受自定义的errMsg的方式构造业务异常
    public BussinessException(CommonError commonError,String errMsg){
        super();
        this.commonError = commonError;
        this.commonError.SetErrMsg(errMsg);
    }
    //异常类中获取错误码和错误信息
    @Override
    public int getErrCode() {
        return this.commonError.getErrCode();
    }

    @Override
    public String getErrMsg() {
        return this.commonError.getErrMsg();
    }

    @Override
    public CommonError SetErrMsg(String errMsg) {
        this.commonError.SetErrMsg(errMsg);
        return  this;
    }
}
